package org.linlinjava.litemall.admin.web;

import io.swagger.models.auth.In;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.service.LitemallTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/admin/topic")
public class AdminTopicController {
    @Autowired
    LitemallTopicService topicService;

    @PostMapping("/create")
    public Object create(@RequestBody LitemallTopic topic) {
        topicService.create(topic);
        return ResponseUtil.ok();
    }

    @PostMapping("/update")
    public Object update(@RequestBody LitemallTopic topic) {
        topicService.update(topic);
        return ResponseUtil.ok();
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody Integer topicId) {
        topicService.delete(topicId);
        return ResponseUtil.ok();
    }

    @GetMapping("/list")
    public Object list() {
        return ResponseUtil.ok(topicService.queryList());
    }

    @GetMapping("/findOne")
    public Object findById(@RequestParam Integer topicId) {
        return ResponseUtil.ok(topicService.findById(topicId));
    }
}
